<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateLoginHistoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('login_records', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id',false,true)->default(0)->comment('用户id');
            $table->tinyInteger('type')->default(1)->comment('用户类型,1普通用户，2后台用户');
            $table->ipAddress('ip')->default('0.0.0.0')->comment('ip');
            $table->string('address',100)->default('')->comment('ip对应的城市');
            $table->string('login_time',12)->default(0)->comment('登陆时间,时间戳');
            $table->index('user_id');
        });
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `login_records` comment '用户登陆记录表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('login_records');
    }
}
